//
//  ERRunnersVC.m
//  EnjoyRunning
//
//  Created by ljm on 2017/3/15.
//  Copyright © 2017年 ljm. All rights reserved.
//

#import "ERRunnersVC.h"

@interface ERRunnersVC ()

@end

/*
 *    圆圈的直径
 */
#define diameter kwidth*0.25

@implementation ERRunnersVC

#pragma mark -- 设置navigation导航条
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:
                                  [UIColor blackColor]}];
                                                                            
    
    UIButton *leftBtn = [[UIButton alloc]initWithFrame:
                         CGRectMake(
                                    0, 0, 30, 30)];
    [leftBtn setImage:[UIImage imageNamed:@"mine_normal"] forState:UIControlStateNormal];
    UIBarButtonItem *selfLeftImage = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem = selfLeftImage;
    
    //right
    UIButton *rightBtn = [[UIButton alloc]initWithFrame:
                          CGRectMake(
                                     0, 0, 30, 30)];
    [rightBtn setImage:[UIImage imageNamed:@"mine_select"] forState:UIControlStateNormal];
    [rightBtn setTintColor:[UIColor whiteColor]];
    UIBarButtonItem *selfRightImage = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = selfRightImage;
    
    self.navigationController.navigationBar.hidden = NO;
    self.tabBarController.tabBar.hidden = NO;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
    
}
    
#pragma mark -- Interface
- (void)setupUI
{
    /*
     *    跑友动态
     */
    UIButton *friendsBtn = [[UIButton alloc] initWithFrame:
                            AAdaptionRect(
                                          kwidth * 0.2/AAdaptionWidth(), kheight * 0.3/AAdaptionWidth(), diameter/AAdaptionWidth(), diameter/AAdaptionWidth())];//initWithFrame:CGRectMake(kwidth * 0.2, kheight * 0.3, diameter, diameter)];
    
    friendsBtn.backgroundColor = [UIColor whiteColor];
    
    /*
     *    切圆角
     */
    friendsBtn.layer.cornerRadius = diameter/2;
    friendsBtn.layer.masksToBounds = YES;
    
    /*
     *    边线
     */
    friendsBtn.layer.borderWidth = 1.5f;
    friendsBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    
    [friendsBtn setTitle:@"跑友动态"
                forState:UIControlStateNormal];
    [friendsBtn setTitleColor:[UIColor blackColor]
                     forState:UIControlStateNormal];


    /*
     *    发现跑友
     */
    UIButton *discoverFriendBtn = [[UIButton alloc]initWithFrame:
                                   AAdaptionRect(
                                                 (kwidth - friendsBtn.frame.origin.x - diameter)/AAdaptionWidth(), kheight * 0.3/AAdaptionWidth(), diameter/AAdaptionWidth(), diameter/AAdaptionWidth())];//CGRectMake(kwidth - friendsBtn.frame.size.width, kheight * 0.3, diameter, diameter)];
    discoverFriendBtn.backgroundColor = [UIColor whiteColor];
    discoverFriendBtn.layer.cornerRadius = diameter/2;
    discoverFriendBtn.layer.masksToBounds = YES;
    discoverFriendBtn.layer.borderWidth = 1.5f;
    discoverFriendBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [discoverFriendBtn setTitle:@"发现跑友" forState:UIControlStateNormal];
    [discoverFriendBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    
    /*
     *    发现跑团
     */
    UIButton *discoverTeamBtn = [[UIButton alloc]initWithFrame:
                                 AAdaptionRect(
                                               friendsBtn.frame.origin.x/AAdaptionWidth(), (friendsBtn.frame.origin.y + diameter * 2)/AAdaptionWidth(), diameter/AAdaptionWidth(), diameter/AAdaptionWidth())];//CGRectMake(kwidth * 0.2, kheight * 0.4 + diameter, diameter, diameter)];
    discoverTeamBtn.backgroundColor = [UIColor whiteColor];
    discoverTeamBtn.layer.cornerRadius = diameter/2;
    discoverTeamBtn.layer.masksToBounds = YES;
    discoverTeamBtn.layer.borderWidth = 1.5f;
    discoverTeamBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [discoverTeamBtn setTitle:@"发现跑团" forState:UIControlStateNormal];
    [discoverTeamBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    /*
     *    排行榜
     */
    UIButton *runnerListBtn = [[UIButton alloc]initWithFrame:
                               AAdaptionRect(
                                             discoverFriendBtn.frame.origin.x/AAdaptionWidth(), (friendsBtn.frame.origin.y + diameter * 2)/AAdaptionWidth(), diameter/AAdaptionWidth(), diameter/AAdaptionWidth())];//CGRectMake(kwidth * 0.3 + diameter, kheight * 0.4 + diameter, diameter, diameter)];
    runnerListBtn.backgroundColor = [UIColor whiteColor];
    runnerListBtn.layer.cornerRadius = diameter/2;
    runnerListBtn.layer.masksToBounds = YES;
    runnerListBtn.layer.borderWidth = 1.5f;
    runnerListBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [runnerListBtn setTitle:@"排行榜" forState:UIControlStateNormal];
    [runnerListBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    
    [friendsBtn addTarget:self
                   action:@selector(inputDetailVC:) forControlEvents:UIControlEventTouchUpInside];
    [discoverFriendBtn addTarget:self
                          action:@selector(inputDetailVC:) forControlEvents:UIControlEventTouchUpInside];
    [discoverTeamBtn addTarget:self
                        action:@selector(inputDetailVC:) forControlEvents:UIControlEventTouchUpInside];
    [runnerListBtn addTarget:self
                      action:@selector(inputDetailVC:) forControlEvents:UIControlEventTouchUpInside];
    
    friendsBtn.tag = 100;
    discoverFriendBtn.tag = 101;
    discoverTeamBtn.tag = 102;
    runnerListBtn.tag = 103;
    
    [self.view addSubview:friendsBtn];
    [self.view addSubview:discoverFriendBtn];
    [self.view addSubview:discoverTeamBtn];
    [self.view addSubview:runnerListBtn];
}
    
#pragma mark -- action
    - (void)inputDetailVC:(UIButton *)btn
    {
        switch (btn.tag) {
            case 100:
            {
                /*
                 *    跑友动态
                 */
                
            }
            break;
            case 101:
            {
                /*
                 *    发现跑友
                 */
                
            }
            break;
            
            case 102:
            {
                /*
                 *    发现跑团
                 */
                
            }
            break;
            
            case 103:
            {
                /*
                 *    排行榜
                 */
                
            }
            break;
            
            default:
            break;
        }
    }


@end
